import 'package:flutter/material.dart';
import 'package:flutter_douban/config/app_colors.dart';
import 'package:flutter_douban/model/note_model.dart';

class NoteDetailHeader extends StatelessWidget {
  final NoteModel model;

  const NoteDetailHeader({Key? key,required this.model}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      alignment: Alignment.center,
      padding: EdgeInsets.only(left: 15, right: 15,top: 20),
      margin: EdgeInsets.only(top: 0),
      color: Colors.white,
      height: kToolbarHeight + MediaQuery.of(context).padding.top,
      width: MediaQuery.of(context).size.width,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          _leftWidget(context),
          _rightWidget(),
        ],
      )
    );
  }

  Widget _rightWidget(){
    return Row(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.center,
      children: [
        SizedBox(
          width: 60,
          height: 28,
          child: TextButton(
            onPressed: () => print(''),
            child: Text(
              '关注',
              style: TextStyle(
                color: Colors.black,
                fontSize: 12,
                fontWeight: FontWeight.bold,
              ),
            ),
            // color: AppColors.yellow,
            // shape: RoundedRectangleBorder(
            //     side: BorderSide(
            //       color: AppColors.yellow,
            //       width: 0.5,
            //     ),
            //     borderRadius: BorderRadius.circular(15)),
          ),
        ),
        SizedBox(width: 12,),
        Image.asset('assets/images/common/calendar_share_icon.png',width: 18,height: 16,color: Colors.black,)
      ],
    );
  }

  Widget _leftWidget(BuildContext context){
    return Row(
      mainAxisAlignment: MainAxisAlignment.start,
      crossAxisAlignment: CrossAxisAlignment.center,
      children: [

        InkWell(
          child: Image.asset('assets/images/common/tab_icon_back.png',width: 20,height: 20,),
          onTap: (){
            Navigator.pop(context);
          },
        ),
        SizedBox(width: 10,),
        Container(
          width: 34,
          height: 34,
          decoration: BoxDecoration(
            color: AppColors.page,
            borderRadius: BorderRadius.circular(17),
          ),
          child: ClipOval(
            child: FadeInImage.assetNetwork(
              placeholder: 'assets/images/common/lazy-1.png',
              image:model.author!.p!,
              fit: BoxFit.cover,
            ),
          ),
        ),
        SizedBox(
          width: 8,
        ),
        Container(
          constraints: BoxConstraints(
            maxWidth: 120,
            maxHeight: 20,
          ),
          child: Text(
            model.author!.n!,
            maxLines: 1,
            overflow: TextOverflow.ellipsis,
            style: TextStyle(
              fontSize: 13,
              fontWeight: FontWeight.bold,
              color: AppColors.black,
            ),
          ),
        ),
        SizedBox(
          width: 12,
        ),
        Text(
          'LV.${model.author!.lvl!}',
          overflow: TextOverflow.ellipsis,
          style: TextStyle(
              fontSize: 11,
              color: AppColors.yellow,
              fontStyle: FontStyle.italic,
              fontWeight: FontWeight.bold),
        ),

      ],
    );
  }
}
